<el-dialog id="rejectForm" title="驳回" :visible.sync="dialogVisible" :width="dialogWidth" top="100px" v-dialog-drag
           :fullscreen="fullscreen" :close-on-click-modal="false" v-cloak>
	<div class="my-dialog-body">
		<el-form ref="form" :model="form" :rules="rules" label-width="120px" size="mini" :disabled="disabled">
			<el-row>
				<el-col :xs="24" :sm="12" :lg="24">
					<el-form-item label="驳回节点" prop="nodeKey">
						<my-select v-model="form.nodeKey" :default-select="0" :data-map="dataMap"></my-select>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :xs="24" :sm="12" :lg="24">
					<el-form-item label="驳回意见" prop="reason">
						<el-input type="textarea" v-model="form.reason"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
	</div>

	<div slot="footer">
		<el-button type="danger" icon="el-icon-back" @click="save(true)"
		           :loading="saveDisabled">驳 回
		</el-button>
		<el-button icon="el-icon-close" @click="dialogVisible = false">取 消</el-button>
	</div>
</el-dialog>

<script>
	var rejectFormVue = new SaveDataVue({
		el: "#rejectForm",
		data: function () {
			return {
				dataMap: [],
				form: {
					taskId: null,
					nodeKey: null,
					reason: null
				},
				rules: {
					nodeKey: {"required": true, "message": "驳回节点必须填写"},
					reason: {"required": true, "message": "驳回意见必须填写"}
				},
			};
		},
		methods: {
			init({taskId, option}) {
				this.form.taskId = taskId;
				this.saveUrl = my.base + '/' + option.url;
				let optionData = myUtil.copyObj(option.data);
				let dataMap = {};
				for (let key in optionData) {
					if (optionData.hasOwnProperty(key)) {
						let value = optionData[key];
						if (typeof value === 'string') {
							dataMap[key] = value;
						} else if (!value['hide']) {
							dataMap[key] = value['name'];
						}
					}
				}
				this.dataMap = dataMap;
			}
		}
	});
</script>
